package com.fjxd.feign.result;

/**
 * @author csw
 * @date 2022/4/5
 * @time 20:25
 * 后台逻辑处理层向Controller交互类型
 */

public class ServiceResult {
    private Integer status;
    private String message;
    private Object data;

    public ServiceResult() {
    }

    public ServiceResult(int status, String message) {
        this.message = message;
    }

    public ServiceResult(int status, String message, Object data) {
        this.message = message;
        this.data = data;
    }

    public static ServiceResult success(String message){
        return new ServiceResult(Status.SUCCESS.getCode(), message);
    }

    public static ServiceResult success(String message, Object data){
        return new ServiceResult(Status.SUCCESS.getCode(), message, data);
    }

public enum Status{
    SUCCESS(0 , "成功"),
    NOUSER(222,"该用户不存在.."),
    ERROR(-1, "严重错误"),
    EXCEPTION(-2, "异常"),
    PARAMERROR(-3, "参数不正确");
    private int code;
    private String message;

    Status(int code, String message){
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}